import { axios } from '@/utils/request'

const api = {
  user: '/user',
  userList: 'sys/user/list',
  userDetail: '/sys/user/detail',
  userSetListOf: '/sys/experiment/nameList',
  userNameList: '/sys/user/nameList',
  userSave: '/sys/experiment/user/save',
  userTestSave: '/sys/experiment/userMedicineConfig/save',
  userTestList: '/sys/experiment/userMedicineConfig/list',
  userTestVersionDetail: '/sys/experimentVersion/detail',
  userTestVersionList: 'sys/experimentVersion/date',
  userTestDetail: '/sys/experiment/detail',
  service: '/service',
  permission: '/permission',
  permissionNoPager: '/permission/no-pager',
  orgTree: '/org/tree',
  accountList: 'sys/sysAccount/list',
  companyList: 'sys/company/loadByAccount',
  accountNameList: 'sys/sysAccount/nameList',
  accountAdd: 'sys/sysAccount/save',
  accountActive: 'sys/sysAccount/active',
  resetPassword: 'sys/sysAccount/resetPassword',
  forgetPassword: 'sys/sysAccount/forgetPassword',
  accountUpdate: 'sys/sysAccount/update',
  accountUpdatePassword: 'sys/sysAccount/updatePassword',
  roleList: 'sys/sysRole/list',
  roleAdd: 'sys/sysRole/save',
  roleUpdate: 'sys/sysRole/update',
  messageList: 'sys/inform/list',
  uploadFile: 'sys/file/upload',
  feedbackList: 'sys/userSuggest/list',
  permissionList: 'sys/permissions/list',
  permissionDetail: 'sys/permissions/load',
  permissionUpdate: 'sys/rolePermissions/saveOrUpdate',
  operationList: 'sys/operationLog/list',
  servicePhone: 'sys//sysServerPhone/load',
  servicePhoneAdd: 'sys/sysServerPhone/saveOrUpdate',
  messageAdd: 'sys/inform/save',
  messageResend: 'sys/inform/resend',
  messageDelete: 'sys/inform/delete'
}

export default api

export function getTestVersionList (parameter) {
  return axios({
    url: api.userTestVersionList,
    method: 'get',
    params: parameter
  })
}

export function getTestVersionDetail (parameter) {
  return axios({
    url: api.userTestVersionDetail,
    method: 'get',
    params: parameter
  })
}

export function getTestDetail (parameter) {
  return axios({
    url: api.userTestDetail,
    method: 'get',
    params: parameter
  })
}

export function getAccountNameList (parameter) {
  return axios({
    url: api.accountNameList,
    method: 'get',
    params: parameter
  })
}

export function getPermissionDetail (parameter) {
  return axios({
    url: api.permissionDetail,
    method: 'get',
    params: parameter
  })
}

// 设置添加受试者
export function postPermissionUpdate (parameter) {
  return axios({
    url: api.permissionUpdate,
    method: 'post',
    data: parameter
  })
}

export function postFileUpload (parameter) {
  return axios({
    url: api.uploadFile,
    method: 'post',
    data: parameter
  })
}

export function postServicePhoneAdd (parameter) {
  return axios({
    url: api.servicePhoneAdd,
    method: 'post',
    data: parameter
  })
}

export function getServicePhone (parameter) {
  return axios({
    url: api.servicePhone,
    method: 'get',
    params: parameter
  })
}

export function getOperationList (parameter) {
  return axios({
    url: api.operationList,
    method: 'get',
    params: parameter
  })
}

export function getPermissionList (parameter) {
  return axios({
    url: api.permissionList,
    method: 'get',
    params: parameter
  })
}

export function getFeedbackList (parameter) {
  return axios({
    url: api.feedbackList,
    method: 'get',
    params: parameter
  })
}

export function getAccountList (parameter) {
  return axios({
    url: api.accountList,
    method: 'get',
    params: parameter
  })
}

export function getCompanyList (parameter) {
  return axios({
    url: api.companyList,
    method: 'get',
    params: parameter
  })
}

// 设置添加受试者
export function postAccountActive (parameter) {
  return axios({
    url: api.accountActive,
    method: 'post',
    data: parameter
  })
}
export function postForgetPassword (parameter) {
  return axios({
    url: api.forgetPassword,
    method: 'post',
    data: parameter
  })
}

export function postResetPassword (parameter) {
  return axios({
    url: api.resetPassword,
    method: 'post',
    data: parameter
  })
}

// 设置添加受试者
export function postAccountAdd (parameter) {
  return axios({
    url: api.accountAdd,
    method: 'post',
    data: parameter
  })
}

export function postAccountUpdate (parameter) {
  return axios({
    url: api.accountUpdate,
    method: 'post',
    data: parameter
  })
}

export function postAccountUpdatePassword (parameter) {
  return axios({
    url: api.accountUpdatePassword,
    method: 'post',
    data: parameter
  })
}

export function getMessageList (parameter) {
  return axios({
    url: api.messageList,
    method: 'get',
    params: parameter
  })
}

export function postMessageAdd (parameter) {
  return axios({
    url: api.messageAdd,
    method: 'post',
    data: parameter
  })
}

export function deleteMessage (parameter) {
  return axios({
    url: api.messageDelete,
    method: 'delete',
    params: parameter
  })
}

export function postMessageResend (parameter) {
  return axios({
    url: api.messageResend,
    method: 'post',
    data: parameter
  })
}

export function getRoleList (parameter) {
  return axios({
    url: api.roleList,
    method: 'get',
    params: parameter
  })
}

export function postRoleAdd (parameter) {
  return axios({
    url: api.roleAdd,
    method: 'post',
    data: parameter
  })
}

export function postRoleUpdate (parameter) {
  return axios({
    url: api.roleUpdate,
    method: 'post',
    data: parameter
  })
}

export function getUserList (parameter) {
//   return axios({
//     url: api.user,
//     method: 'get',
//     params: parameter
//   })
// }
//
// export function getRoleList (parameter) {
  return axios({
    url: api.userList,
    method: 'get',
    params: parameter
  })
}

// 用户详情
export function getUserDetail (parameter) {
  return axios({
    url: api.userDetail,
    method: 'get',
    params: parameter
  })
}

// 用户设置人员名单
export function getUserSetListOf (parameter) {
  return axios({
    url: api.userSetListOf,
    method: 'get',
    params: parameter
  })
}

// 用户设置人员名单
export function getUserNameList (parameter) {
  return axios({
    url: api.userNameList,
    method: 'get',
    params: parameter
  })
}

// 设置添加受试者
export function getUserSave (parameter) {
  return axios({
    url: api.userSave,
    method: 'post',
    data: parameter
  })
}

// 设置试验品发放
export function getUserTestSave (parameter) {
  return axios({
    url: api.userTestSave,
    method: 'post',
    data: parameter
  })
}

// 设置试验品情况列表
export function getUserTestList (parameter) {
  return axios({
    url: api.userTestList,
    method: 'get',
    params: parameter
  })
}

export function getServiceList (parameter) {
  return axios({
    url: api.userList,
    method: 'get',
    params: parameter
  })
}

export function getPermissions (parameter) {
  return axios({
    url: api.permissionNoPager,
    method: 'get',
    params: parameter
  })
}

export function getOrgTree (parameter) {
  return axios({
    url: api.orgTree,
    method: 'get',
    params: parameter
  })
}

// id == 0 add     post
// id != 0 update  put
export function saveService (parameter) {
  return axios({
    url: api.service,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}
